package main

import (
	"fmt"
)

// 编写一个学生考试系统

type Student struct {
	Name  string
	Age   int
	Score int
}

// 将Pupile 和 Graduate 共有的方法也绑定到 *Student
func (stu *Student) ShowInfo() {

	fmt.Printf("学生名=%v 年龄=%v 成绩=%v\n", stu.Name, stu.Age, stu.Score)
}

func (stu *Student) SetScore(score int) {
	// 业务判断
	stu.Score = score
}

// 小学生
type Pupil struct {
	Student
}

func (p *Pupil) testing() {
	fmt.Println("小学生正在考试中...")
}

type Gaduate struct {
	Student
}

func (p *Gaduate) testing() {
	fmt.Println("大学生正在考试中...")
}

func main() {

	pupil := &Pupil{}
	pupil.Student.Name = "tome~"
	pupil.Student.Age = 18
	pupil.testing()

	pupil.Student.SetScore(80)
	pupil.Student.ShowInfo()

	ga := &Gaduate{}
	ga.Student.Name = "皮皮虾"
	ga.Student.Age = 1000
	ga.testing()

	ga.Student.SetScore(800)
	ga.Student.ShowInfo()

}
